#ifndef _INFO_H_
#define _INFO_H_

#pragma warning(disable:4786)

#include <afx.h>
#include <iostream>
#include <map>
#include <winsock2.h>

using namespace std ;

class CInfo
{
public:
	CInfo() { m_iWidth = 320; m_iHeight = 240; };

	enum { KEY = 0xFEDCBA98L };

	// Camera ID
	int		m_iID;

	// Camera Location
	char	m_ip[128];
	unsigned long m_addrOriginal;
	unsigned long m_addrNew;
	int		m_port;

	// Video information
	int		m_iFrameRate;
	int		m_iQualityRange;
	int		m_iBitrate;

	// Video resolution
	int		m_iHeight;
	int		m_iWidth;

	// Password protection
	char	m_strPassword[128];

	void setPassword(LPCTSTR ppw)
	{
		strcpy(m_strPassword, ppw);
	}
	void resetAddress()
	{
		m_addrNew = m_addrOriginal;
	}
	void setAddress(LPCTSTR pip)
	{
		strcpy(m_ip, pip);
		m_addrOriginal = inet_addr(m_ip);
		m_addrNew = m_addrOriginal;
	}
	void setAddress(unsigned long nAddr)
	{
		in_addr a;
		a.S_un.S_addr = nAddr;
		strcpy(m_ip, inet_ntoa(a));
		m_addrOriginal = m_addrNew = nAddr;
	}
	void setNewAddress(unsigned long nAddr)
	{
		m_addrNew = nAddr;
#ifdef _DEBUG
in_addr a;
a.S_un.S_addr = nAddr;
TRACE2("%x: setNewAddress(%s)\n", this, inet_ntoa(a));
#endif // def _DEBUG
	}
	unsigned long getAddress()
	{
#ifdef _DEBUG
in_addr a;
CString sa, sb;
a.S_un.S_addr = m_addrOriginal;
sa = inet_ntoa(a);
a.S_un.S_addr = m_addrNew;
sb = inet_ntoa(a);
TRACE3("%x: getAddress(), m_addrOriginal=%s, m_addrNew=%s\n", this, sa, sb);
#endif // def _DEBUG
		if( (m_addrNew != 0) && (m_addrNew != m_addrOriginal) )
			return m_addrNew;
		return m_addrOriginal;
	}
};

class CRoom
{
public:
	map<CString, CInfo> m_Cameras;
};

class CBuilding
{
public:
	map<CString, CRoom> m_Rooms;
};

class CSite
{
public:
	map<CString, CBuilding> m_Buildings;
};

class CChannelInfo
{
	friend class CRMSEditCameraDlg;
public:
	bool m_bActive;

	CString m_site;
	CString m_building;
	CString m_room;
	CString m_camera;

private:
//	For Edit Camera Information
	bool m_bChange;
	bool m_bDelete;
	bool m_bAdd;
};

#ifdef _IPR_
class CNetmask{
public:
	//char m_ip[128];
	//char m_netmask[128];
	CString m_ip;
	int m_netmask;
	CString m_netid;
};
class CAllowIP
{
public:
	map<CString, CNetmask> m_Netmask;
};
#endif //_IPR_

#endif

